home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / src / tooldebug / vodebug.c next >
Encoding:
C/C++ Source or Header  |  1997-05-08  |  16.3 KB  |  553 lines

  1. #ifndef lint
  2. static char *SccsId = "@(#)VOdebug.c    V1.19    3/13/95";
  3. #endif
  4.  
  5. /*
  6. |    file name -- VOdebug.c
  7. |===================================================================
  8. |
  9. |        copyright (c) 1984, V. I. Corporation
  10. |
  11. |    VOdebug - Checks object counts and statistics
  12. |
  13. |    alan c morse    27 May 87    With much stuff from
  14. |                    C Goldensher's debug.c
  15. |    chris hoffmann     16 mar 92       Add image/icon/pixmap stuff.
  16. |
  17. |===================================================================
  18. |
  19. |    Module description/function:
  20. |    General VO debug and statistics routines for use in testing
  21. |    DV-Tools programs.
  22. |
  23. | ------------------------------------------------------------------
  24. |    Module contents:
  25. |    Function Name         Description
  26. |    -------------    -------------------------------
  27. |    VOdbgCounts    Prints the numbers of each type of object.
  28. |    VOdbgObPts        Prints control points of an object.
  29. |    VOdbgOb        Prints a description of the object
  30. |    VOdbgDqList    Prints contents of a deque
  31. |    VOdbgAttr        Prints contents of attributes structure
  32. |
  33. |====================================================================
  34. */
  35. #include "std.h"
  36. #include "dvstd.h"
  37. #include "VOstd.h"
  38. #include "GRfundecl.h"
  39. #include "VOfundecl.h"
  40. #include "VUfundecl.h"
  41.  
  42. /***************** Begin Function Declarations *************/
  43. LOCAL void PrintCount V_P_ ((char *ObjectName, LONG count, LONG *oldcountp));
  44. /***************** End Function Declarations *************/
  45.  
  46.  
  47. /*===================================================================
  48. |
  49. |    VOdbgCounts
  50. |    Prints out the numbers of each kind of VO object.
  51. |    For each object it also prints the change in the number for
  52. |    that object from the last time it was called.
  53. */
  54. LONG arCount = 0, ciCount = 0, dqCount = 0, dgCount = 0, drCount = 0, elCount = 0,
  55.   hpCount = 0, inCount = 0, itCount = 0, lnCount = 0, loCount = 0,
  56.   ptCount = 0, pyCount = 0, reCount = 0, sdCount = 0, txCount = 0,
  57.   ttCount = 0, vdCount = 0, vpCount = 0, xfCount = 0, vtCount = 0,
  58.   stCount = 0, skCount = 0, ruCount = 0, acCount = 0, dyCount = 0,
  59.   edCount = 0, noCount = 0, icCount = 0, imCount = 0, pmCount = 0,
  60.   sfCount = 0;
  61.  
  62. LOCAL void 
  63. PrintCount (ObjectName, count, oldcountp)
  64.      char *ObjectName;
  65.      LONG count;
  66.      LONG *oldcountp;
  67.  
  68. /*------ Original comments: ----*/
  69. #if 0
  70.      LOCAL VOID PrintCount (ObjectName, count, oldcountp)
  71.      CHAR *ObjectName;          /* Name of the object */
  72.      LONG count;                /* Current number of objects of this type */
  73.      LONG *oldcountp;           /* Address of where old count is stored */
  74. #endif
  75. /*---- Original comments ----*/
  76.  
  77. {
  78.   S_PRINTF (ObjectName);
  79.   S_PRINTF (":%-5d", (int)count);
  80.   if (*oldcountp > count)
  81.     S_PRINTF ("-%-5d  ", (INT) (*oldcountp - count));
  82.   else if (*oldcountp == count)
  83.     S_PRINTF ("+0      ");
  84.   else                          /* *oldcountp < count ) */
  85.     S_PRINTF ("+%-5d  ", (INT) (count - *oldcountp));
  86.   *oldcountp = count;
  87. }
  88.  
  89. void 
  90. VOdbgCounts ()
  91. {
  92.   PrintCount ("ar", VOarStatistic (OBJECT_COUNT), &arCount);
  93.   PrintCount ("ci", VOciStatistic (OBJECT_COUNT), &ciCount);
  94.   PrintCount ("dg", VOdgStatistic (OBJECT_COUNT), &dgCount);
  95.   PrintCount ("dq", VOdqStatistic (OBJECT_COUNT), &dqCount);
  96.   PrintCount ("dr", VOdrStatistic (OBJECT_COUNT), &drCount);
  97.   PrintCount ("dy", VOdyStatistic (OBJECT_COUNT), &dyCount);
  98.   S_PUTCHAR ('\n');
  99.   PrintCount ("ed", VOedStatistic (OBJECT_COUNT), &edCount);
  100.   PrintCount ("el", VOelStatistic (OBJECT_COUNT), &elCount);
  101.   PrintCount ("hp", VOhpStatistic (OBJECT_COUNT), &hpCount);
  102.   PrintCount ("ic", VOicStatistic (OBJECT_COUNT), &icCount);
  103.   PrintCount ("im", VOimStatistic (OBJECT_COUNT), &imCount);
  104.   PrintCount ("in", VOinStatistic (OBJECT_COUNT), &inCount);
  105.   PrintCount ("it", VOitStatistic (OBJECT_COUNT), &itCount);
  106.   S_PUTCHAR ('\n');
  107.   PrintCount ("ln", VOlnStatistic (OBJECT_COUNT), &lnCount);
  108.   PrintCount ("lo", VOloStatistic (OBJECT_COUNT), &loCount);
  109.   PrintCount ("no", VOnoStatistic (OBJECT_COUNT), &noCount);
  110.   PrintCount ("pm", VOpmStatistic (OBJECT_COUNT), &pmCount);
  111.   PrintCount ("pt", VOptStatistic (OBJECT_COUNT), &ptCount);
  112.   PrintCount ("py", VOpyStatistic (OBJECT_COUNT), &pyCount);
  113.   S_PUTCHAR ('\n');
  114.   PrintCount ("re", VOreStatistic (OBJECT_COUNT), &reCount);
  115.   PrintCount ("ru", VOruStatistic (OBJECT_COUNT), &ruCount);
  116.   PrintCount ("sd", VOsdStatistic (OBJECT_COUNT), &sdCount);
  117.   PrintCount ("sk", VOskStatistic (OBJECT_COUNT), &skCount);
  118.   PrintCount ("st", VOstStatistic (OBJECT_COUNT), &stCount);
  119.   PrintCount ("tt", VOttStatistic (OBJECT_COUNT), &ttCount);
  120.   S_PUTCHAR ('\n');
  121.   PrintCount ("tx", VOtxStatistic (OBJECT_COUNT), &txCount);
  122.   PrintCount ("vd", VOvdStatistic (OBJECT_COUNT), &vdCount);
  123.   PrintCount ("vp", VOvpStatistic (OBJECT_COUNT), &vpCount);
  124.   PrintCount ("vt", VOvtStatistic (OBJECT_COUNT), &vtCount);
  125.   PrintCount ("xf", VOxfStatistic (OBJECT_COUNT), &xfCount);
  126.   PrintCount ("sf", VOsfStatistic (OBJECT_COUNT), &sfCount);
  127.   S_PUTCHAR ('\n');
  128.   /*PrintCount( "ac", VOacStatistic(OBJECT_COUNT), &acCount );*/
  129. }
  130.  
  131. /*=============================================================
  132. |
  133. |    VOdbgObPts:
  134. |    Print the control points for the given object.
  135. |    Returns the number of control points in the object.
  136. */
  137. int 
  138. VOdbgObPts (obj)
  139.      OBJECT obj;
  140. {
  141.   INT numpts, i;
  142.  
  143.   (VOID) S_PRINTF ("object: 0x%x\n", (unsigned)obj);
  144.  
  145.   if (!VOobValid (obj))
  146.     {
  147.       (VOID) S_PRINTF ("\tinvalid object\n");
  148.       return (0);
  149.     }
  150.   else
  151.     {
  152.       numpts = (INT) VOobPtGet (obj, 0);
  153.       for (i = 1; i <= numpts; ++i)
  154.         {
  155.           OBJECT point;
  156.           DV_POINT wcs_pt, offset;
  157.  
  158.           point = VOobPtGet (obj, i);
  159.           VOptGet (point, &wcs_pt, &offset);
  160.           (VOID) S_PRINTF ("\tpoint %d:", i);
  161.           (VOID) S_PRINTF ("(%d,%d)", (int)wcs_pt.x, (int)wcs_pt.y);
  162.           (VOID) S_PRINTF (" offset(%d,%d)\n", (int)offset.x, (int)offset.y);
  163.         }
  164.       return (numpts);
  165.     }
  166. }
  167.  
  168. /*=============================================================
  169. |
  170. |    VOdbgDqList
  171. |    List useful information about each object in the deque
  172. */
  173. int 
  174. VOdbgDqList (deque)
  175.      OBJECT deque;
  176. {
  177.  
  178.   if (VOdqValid (deque))
  179.     {
  180.       VOdqTraverse (deque, (VOOBTRAVERSEFUN) VOdbgOb, NULL);
  181.       return (VOdqSize (deque));
  182.     }
  183.   else
  184.     return (-1);
  185. }
  186.  
  187. /*=============================================================
  188. |
  189. |    VOdbgAttr
  190. |    Prints Attributes data structure.
  191. */
  192. void 
  193. VOdbgAttr (attr)
  194.      ATTRIBUTES *attr;
  195. {
  196.   if (attr->foreground_color != EMPTY_FIELD)
  197.     (VOID) S_PRINTF ("\tforeground: 0x%lx",
  198.                      attr->foreground_color);
  199.  
  200.   if (attr->background_color != EMPTY_FIELD)
  201.     (VOID) S_PRINTF ("\tbackground: 0x%lx",
  202.                      attr->background_color);
  203.  
  204.   if (attr->line_width != EMPTY_FIELD)
  205.     (VOID) S_PRINTF ("\n\tline width: %d", attr->line_width);
  206.  
  207.   if (attr->line_type != EMPTY_FIELD)
  208.     (VOID) S_PRINTF ("\ttype: %d\n", attr->line_type);
  209.  
  210.   if (attr->fill_status != EMPTY_FIELD)
  211.     if (attr->fill_status == FILLED_OBJECT)
  212.       (VOID) S_PRINTF ("\tfilled");
  213.     else
  214.       (VOID) S_PRINTF ("\tnot filled");
  215.  
  216.   if (attr->text_direction != EMPTY_FIELD)
  217.     if (attr->text_direction == VERTICAL_TEXT)
  218.       (VOID) S_PRINTF ("\n\tvertical");
  219.     else
  220.       (VOID) S_PRINTF ("\n\thorizontal");
  221.  
  222.   if (attr->text_position != EMPTY_FIELD)
  223.     {
  224.       DV_BOOL centered = NO;
  225.  
  226.       S_PUTCHAR ('\t');
  227.  
  228.       if (attr->text_position & AT_TOP_EDGE)
  229.         (VOID) S_PRINTF ("Top ");
  230.       else if (attr->text_position & AT_BOTTOM_EDGE)
  231.         (VOID) S_PRINTF ("Bottom ");
  232.       else
  233.         centered = YES;
  234.  
  235.       if (attr->text_position & AT_LEFT_EDGE)
  236.         (VOID) S_PRINTF ("Left ");
  237.       else if (attr->text_position & AT_RIGHT_EDGE)
  238.         (VOID) S_PRINTF ("Right ");
  239.       else
  240.         centered = YES;
  241.  
  242.       if (centered)
  243.         (VOID) S_PRINTF ("Center justified");
  244.       else
  245.         (VOID) S_PRINTF ("justified");
  246.     }
  247.  
  248.   if (attr->text_font != EMPTY_FIELD)
  249.     (VOID) S_PRINTF ("\tfont: %d", attr->text_font);
  250.  
  251.   if (attr->text_size != EMPTY_FIELD)
  252.     (VOID) S_PRINTF ("\tsize: %d", attr->text_size);
  253.  
  254.   if (attr->arc_direction != EMPTY_FIELD)
  255.     if (attr->arc_direction == COUNTER_CLOCKWISE)
  256.       (VOID) S_PRINTF ("\n\tcounter-clockwise");
  257.     else
  258.       (VOID) S_PRINTF ("\n\tclockwise");
  259.  
  260.   if (attr->curve_type != EMPTY_FIELD)
  261.     if (attr->curve_type == CLOSED_ENDS)
  262.       (VOID) S_PRINTF ("\n\tclosed end conditions");
  263.     else if (attr->curve_type == OPEN_ENDS)
  264.       (VOID) S_PRINTF ("\n\topen end conditions");
  265.     else if (attr->curve_type == FLOATING_ENDS)
  266.       (VOID) S_PRINTF ("\n\tfloating end conditions");
  267.  
  268.   S_PUTCHAR ('\n');
  269. }
  270.  
  271. /*=============================================================
  272. |
  273. |    VOdbgOb
  274. |    Prints statistics about the specified object
  275. */
  276.  
  277. #define    S_UNKNOWN_TYPE    "UNKNOWN TYPE"
  278. #define    S_UNLISTED_TYPE    "UNLISTED TYPE"
  279. #define    S_HIGHEST_LISTED_TYPE    37
  280. LOCAL CHAR *obj_type[]=
  281. {
  282.   "NOT_AN_OBJECT",              /* 0 */
  283.   "ARC",                        /* 1 */
  284.   "PIXMAP",                     /* 2 */
  285.   "CIRCLE",                     /* 3 */
  286.   "COLOR",                      /* 4 */
  287.   "IMAGE",                      /* 5 */
  288.   "DATASOURCE",                 /* 6 */
  289.   "DEQUE",                      /* 7 */
  290.   "DG",                         /* 8 */
  291.   "DRAWING",                    /* 9 */
  292.   "HEAP",                       /* 10 */
  293.   "LINE",                       /* 11 */
  294.   "LOCATION",                   /* 12 */
  295.   "ICON",                       /* 13 */
  296.   "PARAMETER",                  /* 14 */
  297.   "DV_POINT",                      /* 15 */
  298.   "POLYGON",                    /* 16 */
  299.   "RECTANGLE",                  /* 17 */
  300.   "RGB",                        /* 18 */
  301.   "SCREEN",                     /* 19 */
  302.   "STREAM",                     /* 20 */
  303.   "SUBDRAWING",                 /* 21 */
  304.   "DV_TEXT",                       /* 22 */
  305.   "THRESHTABLE",                /* 23 */
  306.   "VD",                         /* 24 */
  307.   "VIEWPORT",                   /* 25 */
  308.   "XFORM",                      /* 26 */
  309.   "INPUT",                      /* 27 */
  310.   "INPUT_TECHNIQUE",            /* 28 */
  311.   "VECTOR_TEXT",                /* 29 */
  312.   "EDGE",                       /* 30 */
  313.   "NODE",                       /* 31 */
  314.   "ELLIPSE",                    /* 32 */
  315.   "SLOTKEY",                    /* 33 */
  316.   "SLOTTABLE",                  /* 34 */
  317.   "ACTION",                     /* 35 */
  318.   "RULE",                       /* 36 */
  319.   "DYNAMIC"                     /* 37 */
  320. };
  321.  
  322.  
  323. BOOLPARAM 
  324. VOdbgOb (obj)
  325.      OBJECT obj;
  326. {
  327.   INT type;                     /* type of object */
  328.   CHAR *s_type;
  329.   LONG index;                   /* Color index */
  330.   INT r, g, b;                  /* Color red, green, and blue components */
  331.   INT n;
  332.   FLOAT matrix[3][3];
  333.  
  334.   type = VOobType (obj);
  335.   if (type < LOWEST_TYPE_CODE || type > S_HIGHEST_LISTED_TYPE)
  336.     {
  337.       if (type > HIGHEST_TYPE_CODE)
  338.         s_type = S_UNLISTED_TYPE;
  339.       else
  340.         s_type = S_UNKNOWN_TYPE;
  341.     }
  342.   else
  343.     s_type = obj_type[type];
  344.  
  345.   (VOID) S_PRINTF ("object: 0x%x", (unsigned)obj);
  346.   if (VOobValid (obj))
  347.     {
  348.       ATTRIBUTES attr;
  349.  
  350.       (VOID) S_PRINTF ("\ttype: %s (%d)\n", s_type, type);
  351.  
  352.       /* print attributes */
  353.       VOobAtGet (obj, &attr);   /* get attributes of object */
  354.       VOdbgAttr (&attr);
  355.  
  356.       /* processing specific to each type */
  357.       switch (type)
  358.         {
  359.         case OT_ARC:
  360.         case OT_CIRCLE:
  361.         case OT_ELLIPSE:
  362.           break;
  363.  
  364.         case OT_COLOR:
  365.         case OT_RGB:
  366.           index = VOcoIndex (obj);
  367.           (VOID) S_PRINTF ("\tindex: %ld", index);
  368.           GRindextorgb (index, &r, &g, &b);
  369.           (VOID) S_PRINTF ("\tR:%d G:%d B:%d\n", r, g, b);
  370.           break;
  371.  
  372.         case OT_DATASOURCE:
  373.           break;
  374.  
  375.         case OT_DEQUE:
  376.           (VOID) S_PRINTF ("\nDEQUE length: %d\n", VOdqSize (obj));
  377.           break;
  378.  
  379.         case OT_DG:
  380.           VUdbgDgp (VOdgAddress (obj));
  381.           break;
  382.  
  383.         case OT_DRAWING:
  384.           break;
  385.  
  386.         case OT_HEAP:
  387.           break;
  388.  
  389.         case OT_ICON:
  390.           {
  391.             OBJECT pixmap, mask;
  392.             INT h, w;
  393.  
  394.             VOicGet (obj, V_IC_PIXMAP, &pixmap,
  395.                      V_IC_MASK_PIXMAP, &mask,
  396.                      V_IC_HEIGHT, &h,
  397.                      V_IC_WIDTH, &w,
  398.                      V_IC_ATTR_ARGEND);
  399.             (VOID) S_PRINTF ("\tpixmap: 0x%x", (unsigned)pixmap);
  400.             if (mask)
  401.               (VOID) S_PRINTF ("\tmask: 0x%x", (unsigned)mask);
  402.             (VOID) S_PRINTF ("\t size: %dx%d", w, h);
  403.             (VOID) S_PRINTF ("\n");
  404.           }
  405.           break;
  406.  
  407.         case OT_IMAGE:
  408.           {
  409.             OBJECT pixmap, mask;
  410.  
  411.             VOimGet (obj, V_IM_PIXMAP, &pixmap,
  412.                      V_IM_MASK_PIXMAP, &mask,
  413.                      V_IM_ATTR_ARGEND);
  414.             (VOID) S_PRINTF ("\tpixmap: 0x%x", (unsigned)pixmap);
  415.             if (mask)
  416.               (VOID) S_PRINTF ("\tmask: 0x%x", (unsigned)mask);
  417.             (VOID) S_PRINTF ("\n");
  418.           }
  419.           break;
  420.  
  421.         case OT_INPUT:
  422.           break;
  423.  
  424.         case OT_INPUT_TECHNIQUE:
  425.           break;
  426.  
  427.         case OT_LINE:
  428.           break;
  429.  
  430.         case OT_LOCATION:
  431.           {
  432.             DV_POINT *pt;
  433.  
  434.             pt = VOloScpGet (obj);      /* screen coordinates */
  435.             if (pt)
  436.               (VOID) S_PRINTF ("\tscreen coords: (%d,%d)",
  437.                                (int)pt->x, (int)pt->y);
  438.             pt = VOloWcpGet (obj);      /* world coordinates */
  439.             if (pt)
  440.               (VOID) S_PRINTF ("\tworld coords: (%d,%d)\n",
  441.                                (int)pt->x, (int)pt->y);
  442.             else
  443.               S_PRINTF ("\n");
  444.           }
  445.           break;
  446.  
  447.  
  448.         case OT_PARAMETER:
  449.           break;
  450.  
  451.         case OT_PIXMAP:
  452.           {
  453.             INT h, w;
  454.             CHAR *fn;
  455.             DV_BOOL included;
  456.  
  457.             VOpmGet (obj, V_PM_HEIGHT, &h,
  458.                      V_PM_WIDTH, &w,
  459.                      V_PM_FILENAME, &fn,
  460.                      V_PM_INCLUDE_PIXELS, &included,
  461.                      V_PM_ATTR_ARGEND);
  462.             (VOID) S_PRINTF ("\tsize: %dx%d pixels", w, h);
  463.             if (included)
  464.               (VOID) S_PRINTF ("\t(included) ");
  465.             else
  466.               (VOID) S_PRINTF ("\t(referenced) ");
  467.             if (fn)
  468.               (VOID) S_PRINTF ("file: %s\n", fn);
  469.  
  470.           }
  471.           break;
  472.  
  473.         case OT_POINT:
  474.           {
  475.             DV_POINT wcs_pt, pix_offset;
  476.  
  477.             VOptGet (obj, &wcs_pt, &pix_offset);
  478.             (VOID) S_PRINTF ("\t(%d,%d)", (int)wcs_pt.x, (int)wcs_pt.y);
  479.             (VOID) S_PRINTF ("\toffset (%d,%d)\n",
  480.                              (int)pix_offset.x, (int)pix_offset.y);
  481.           }
  482.           break;
  483.  
  484.         case OT_POLYGON:
  485.         case OT_RECTANGLE:
  486.         case OT_SCREEN:
  487.         case OT_STREAM:
  488.         case OT_SUBDRAWING:
  489.           break;
  490.  
  491.         case OT_TEXT:
  492.           (VOID) S_PRINTF ("\tstring: \"%s\"\n", VOtxGetString (obj));
  493.           break;
  494.  
  495.         case OT_THRESHTABLE:
  496.           break;
  497.  
  498.         case OT_VD:
  499.           VUdbgVdp (VOvdAddress (obj));
  500.           break;
  501.  
  502.         case OT_VIEWPORT:
  503.           break;
  504.  
  505.         case OT_VTEXT:
  506.           (VOID) S_PRINTF ("\tstring: \"%s\"\n", VOvtGetString (obj));
  507.           break;
  508.  
  509.         case OT_SFTEXT:
  510.           (VOID) S_PRINTF ("\tstring: \"%s\"\n", VOsfGetString (obj));
  511.           break;
  512.  
  513.         case OT_XFORM:
  514.           (VOID) S_PRINTF ("\tscale factor: %g\n", VOxfScale (obj));
  515.           VOxfMatGet (obj, matrix);
  516.           for (n = 0; n < 3; n++)
  517.             S_PRINTF ("\tmatrix row%d: %-10g %-10g %-10g\n", n + 1,
  518.                       matrix[n][0], matrix[n][1], matrix[n][2]);
  519.           break;
  520.  
  521.         case OT_SLOTTABLE:
  522.           break;
  523.  
  524.         case OT_SLOTKEY:
  525.           break;
  526.  
  527.         case OT_ACTION:
  528.           break;
  529.  
  530.         case OT_RULE:
  531.           break;
  532.  
  533.         case OT_DYNAMIC:
  534.           break;
  535.  
  536.         case OT_NODE:
  537.           break;
  538.  
  539.         case OT_EDGE:
  540.           break;
  541.  
  542.         default:
  543.           (VOID) S_PRINTF (
  544.                          "warning: valid object with unknown type\n");
  545.           break;
  546.         }
  547.     }
  548.   else
  549.     (VOID) S_PRINTF ("\tinvalid object\n");
  550.  
  551.   return (NO);
  552. }
  553.